import { AgGridReact, AgGridReactProps } from "ag-grid-react";
import { AllCommunityModule, ModuleRegistry } from "ag-grid-community";
import type { ColDef } from "ag-grid-community";
ModuleRegistry.registerModules([AllCommunityModule]);
interface DataGridProps
  extends Omit<AgGridReactProps, "rowData" | "columnDefs"> {
  rowData?: any[];
  columnDefs?: ColDef[];
  className?: string;
}

const DataGrid = ({ rowData, columnDefs, ...gridProps }: DataGridProps) => {
  return (
    <div className="h-[600px] rounded-lg shadow-lg border border-gray-200 flex-grow">
      <AgGridReact
        rowData={rowData}
        columnDefs={columnDefs}
        pagination={true}
        paginationPageSizeSelector={[10, 20, 50, 100]}
        paginationPageSize={10}
        {...gridProps} // Spread additional AG Grid props
      />
    </div>
  );
};
export default DataGrid;
